package com.yh.csx.crm.appapi.controller;

import com.yh.csx.crm.service.response.IndexResp;
import com.yh.csx.crm.core.entity.CommonResponse;
import com.yh.csx.crm.service.ApprovalService;
import com.yh.csx.crm.service.vo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * IndexController class
 *
 * @author huyalin
 * @date 2019/2/25
 */
@Api("APP-首页")
@RestController
@RequestMapping("/app/index")
public class IndexController extends BaseController {

    @Autowired
    ApprovalService approvalService;

    @ApiOperation("首页待办任务统计列表")
    @GetMapping("")
    public CommonResponse<IndexResp> getIndexTodoList() {
        return super.visit(() -> {
            User user = new User(super.getUserId(), super.getUserName());
            return approvalService.getIndexTodoList(user);
        });
    }
}
